package com.lhl.security.jwt.service;

import com.lhl.security.jwt.dao.SysUserDao;
import com.lhl.security.jwt.domain.dto.JwtUser;
import com.lhl.security.jwt.domain.entity.SysUser;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: com.lhl.security.jwt.service.JwtUserDetailsService
 * @description: TODO 类描述
 * @author: king
 * @date: 2020-11-09
 **/
@Api(tags = "JwtUserDetailsService", produces = "")
@Service
public class JwtUserDetailsService implements UserDetailsService {
    @Autowired
    private SysUserDao sysUserDao;
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        sysUserDao.findByUsername(s);
        return new JwtUser(sysUserDao.findByUsername(s).orElse(new SysUser()));
    }
}
